<?php

namespace App\Http\Controllers;

use App\Admin;
use Illuminate\Http\Request;
use Auth;
class PassportController extends Controller
{
    //
    public function __construct()
    {
        $this->middleware('guest')->except(['logout']);

    }
    /**
     * 登录页面
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function login()
    {
        return view('passport.login');
    }

    //登录处理
    public function loginAction(Request $request)
    {
        return Admin::Login($request->name,$request->password);
//        $return = Admin::Login($request->name,$request->password);
//        if ($return['status'] === 1) {
//            return redirect('/')->with($return);
//        } else {
//            return back()->with('status',2)->with('message', $return['message']);
//        }
    }

    /**
     * 登出
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
    public function logout()
    {
        Auth::logout();
        return redirect('/');
    }
}
